﻿using JT808Protocol.Common;
using System;
using System.Collections.Generic;

namespace JT808Protocol.Models.BodyParserStrategy.Others
{
    /// <summary>
    /// 报警附件上传指令
    /// </summary>
    public class PrAlarmAttachmentUpload_0x9208 : IJT808Body
    {
        /// <summary>
        /// 附件服务器IP长度
        /// </summary>
        public byte AttachmentServerIPLen { get; set; }

        /// <summary>
        /// 附件服务器IP
        /// </summary>
        public string AttachmentServerIP { get; set; }

        /// <summary>
        /// 附件服务器端口(TCP)
        /// </summary>
        public ushort AttachmentServer_TcpPort { get; set; }

        /// <summary>
        /// 附件服务器端口(Udp),默认是0
        /// </summary>
        public ushort AttachmentServer_UdpPort { get; set; } = 0;

        /// <summary>
        /// 报警标识号（粤标长度为40，苏标为16）
        /// </summary>
        public byte[] AlarmLogo { get; set; }

        /// <summary>
        /// 报警编号（长度32 Guid）
        /// </summary>
        public string AlarmId { get; set; }

        /// <summary>
        /// 预留（长度16）
        /// </summary>
        public byte[] Reserved { get; set; } = new byte[16];

        public override IJT808Body ReadBody(ReadOnlySpan<byte> data, ref int index)
        {
            throw new NotImplementedException();
        }

        public override List<byte> WriteToBytes()
        {
            List<byte> result = new List<byte>();
            result.Add(AttachmentServerIPLen);
            result.AddRange(ParseHelper.AsciiBytes(AttachmentServerIP));
            result.AddRange(ParseHelper.Bytes(AttachmentServer_TcpPort));
            result.AddRange(ParseHelper.Bytes(AttachmentServer_UdpPort));
            result.AddRange(AlarmLogo);
            result.AddRange(ParseHelper.AsciiBytes(AlarmId));
            result.AddRange(Reserved);

            return result;
        }
    }
}